
var post_data = require('../data/post-data.js')


Page({
  data:{
  
  },
  onLoad:function(options){
    // 生命周期函数--监听页面加载
    this.intializeData()

  },
  onShow:function(){
    this.intializeData()
  },
  onPostTap:function(event){
    var postId = event.currentTarget.dataset.postid
    wx.navigateTo({
      url:"post-detail/post-detail?postId="+postId
    })
  },
  onSwiperTap:function(event){
    var postId = event.target.dataset.postid

        wx.navigateTo({
          url:"post-detail/post-detail?postId="+postId
        })
  },
  intializeData:function(){

        var postsView = wx.getStorageSync('postsView')
        var posts = post_data.posts
        for(var i=0;i<posts.length;i++){
          posts[i].postView = (postsView&&postsView[i])?postsView[i]:0
        }
    this.setData({
        posts:posts,
    })
    
  }
  
})

